package springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springboot.config.interceptor.JwtInterceptor;
import springboot.config.interceptor.JwtInterceptorx;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(JwtInterceptor())
                .addPathPatterns("/ljhsaddress/**","/user/page/**","/user","/user/realname/**")
                .excludePathPatterns("/user/login","/user/register","/collector/login","/collector/register","/file/**","/ljhsgoods");    // 拦截所有请求，通过判断token是否合法来决定需要登录
        registry.addInterceptor(JwtInterceptorx())
                .addPathPatterns("/ljhsorder/collector/**")
                .excludePathPatterns("/user/login","/user/register","/collector/login","/collector/register","/file/**","/ljhsgoods");

    }
    @Bean
    public  JwtInterceptor JwtInterceptor(){
        return new JwtInterceptor();
    }
    @Bean
    public  JwtInterceptorx JwtInterceptorx(){
        return new JwtInterceptorx();
    }
}
